<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>
<body>
	<script type="text/javascript">
	// Map 对象接收任何类型的键
	const testMap = new Map()

	let str = '今天不学习',
		num = 666,
		keyFunction = function() {},
		keySymbol = Symbol('web'),
		keyNull = null,
		keyUndefined = undefined,
		keyNaN = NaN
	// 添加键值对
	// 基本用法
	testMap.set('key','value')

	testMap.set(str, '明天变辣鸡')
	testMap.set(num, '前端Sneaker')
	testMap.set(keyFunction, '你的函数写的好棒棒哦')
	testMap.set(keySymbol, '大前端')
	testMap.set(keyNull, '我是个Null')
	testMap.set(keyUndefined, '我是个Undifined')
	testMap.set(keyNaN, '我是个NaN')

	console.log(testMap.get(function() {}))

	testMap.get(function () {}) //undefined
	testMap.get(Symbol('Web')) //undefined

	//虽然NaN !== NaN 但是作为Map键名并无区别
	testMap.get(NaN) //"我是个NaN"
	testMap.get(Number('NaN')) //"我是个NaN"

	// 原型 Prototype
	const countWords = (words) => {
	  const counts = { };
	  for (const word of words) {
	    counts[word] = (counts[word] || 0) + 1;
	  }
	  return counts;
	};
	const counts = countWords(['constructor', 'creates', 'a', 'bug']);
	// {constructor: "function Object() { [native code] }1", creates: 1, a: 1, bug: 1}
	console.log(counts)

	// 迭代器
	
	</script>
</body>
</html>